﻿package mortal.game.view.msgbroad
{
    import com.gengine.utils.*;
    import com.gengine.utils.pools.*;
    import com.mui.core.*;
    import flash.display.*;
    import flash.geom.*;
    import flash.text.*;
    import mortal.common.*;
    import mortal.common.font.*;
    import mortal.component.*;
    import mortal.component.gconst.*;
    import mortal.game.model.*;
    import mortal.game.resource.*;

    public class RollRadioItem extends Sprite
    {
        private var _textField:TextField;
        private var _info:RollRadioInfo;
        private var _skin:Bitmap;
        private var _width:int;
        private var _height:int = 30;
        private var _bmpLabel:BitmapLabel;

        public function RollRadioItem(param1:int = 750)
        {
            this._width = param1;
            this.initUI();
            return;
        }// end function

        private function initUI() : void
        {
            mouseEnabled = false;
            mouseChildren = false;
            this.scrollRect = new Rectangle(0, 0, this._width, this._height);
            this._skin = GlobalClass.getScaleBitmap(ImagesConst.rollmsgbg, new Rectangle(130, 10, 5, 5));
            this._skin.width = this._width;
            this._skin.height = this._height;
            addChild(this._skin);
            this._textField = new TextField();
            this._textField.selectable = false;
            this._textField.height = 24;
            this._textField.filters = [FilterConst.nameGlowFilter];
            var _loc_1:* = new GTextFormat(FontUtil.songtiName, 14, 16776960, false, null, null, null, null, TextFormatAlign.LEFT);
            _loc_1.letterSpacing = 2;
            this._textField.defaultTextFormat = _loc_1;
            this._textField.autoSize = TextFieldAutoSize.LEFT;
            this._bmpLabel = new BitmapLabel();
            this._bmpLabel.textField = this._textField;
            this._bmpLabel.x = 0;
            this._bmpLabel.y = 7;
            addChild(this._bmpLabel);
            this.cacheAsBitmap = true;
            return;
        }// end function

        public function updateData(param1:RollRadioInfo) : void
        {
            this._info = param1;
            this._bmpLabel.htmlText = HTMLUtil.addColor(param1.str, "#ffffff");
            this._bmpLabel.x = this._width;
            var _loc_2:* = this._info;
            var _loc_3:* = this._info.count + 1;
            _loc_2.count = _loc_3;
            return;
        }// end function

        public function frameScript() : void
        {
            this._bmpLabel.x = this._bmpLabel.x - this._info.speed;
            return;
        }// end function

        public function dispose() : void
        {
            if (this._info)
            {
                ObjectPool.disposeObject(this._info);
            }
            this._info = null;
            this._bmpLabel.x = this._width;
            return;
        }// end function

        public function get running() : Boolean
        {
            return this._info && this._bmpLabel.x >= -this._bmpLabel.textWidth;
        }// end function

        public function get hasEnd() : Boolean
        {
            return this._info && this._info.count >= this._info.totalCount;
        }// end function

        public function get info() : RollRadioInfo
        {
            return this._info;
        }// end function

        override public function get height() : Number
        {
            return this._height;
        }// end function

        override public function get width() : Number
        {
            return this._width;
        }// end function

    }
}
